import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 创建对象的方式：
 * 1、new
 * 2、
 * User: 晓星航
 * Date: 2022-12-18
 * Time: 11:47
 */
class Person implements Cloneable{
    public int age;


    public void eat() {
        System.out.println("吃！");
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class TestDemo {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person = new Person();
        person.age = 99;
        Person person2 = (Person) person.clone();
        person2.age = 199;
        System.out.println(person);
        System.out.println(person2);

    }
}
